//创建一个客户端
const ws = new WebSocket('ws://localhost:1234');
const fs = require('fs')
ws.onopen = () => {
    ws.send(JSON.stringify({
        "command": "login",
        "id": "editor"
    }));
}

ws.onmessage = (event) => {
    const data = JSON.parse(event.data);
    if (data.command === 'save') {
        fs.writeFileSync('assets/scenes/main.yaml', data.data, 'utf-8')
    }
};

const button = document.createElement('button');
button.innerText = "保存1111!";
button.onclick = () => {

}
document.body.appendChild(button);


button.onclick = () => {
    const fs = require('fs');
    fs.writeFileSync('1.txt', 'lalalallalalalla');
}


